#ifndef DPQ_HEADER_INCLUDED
#define DPQ_HEADER_INCLUDED
typedef struct IDirectDrawSurface       FAR *LPDIRECTDRAWSURFACE;
typedef struct IDirectDraw FAR *LPDIRECTDRAW;

#define teste(a,b) if (!a) { OutputDebugString("Erreur : ");OutputDebugString(b);OutputDebugString("\n");return 0; }
#define DXteste(a,b) if (FAILED(a)) { OutputDebugString("Erreur : ");OutputDebugString(b);OutputDebugString("\n");return 0; }
#define essaie(a,b) if (!a) { OutputDebugString("Erreur : ");OutputDebugString(b);OutputDebugString("\n");}
#define SAFE_RELEASE(a) if (a!=NULL) a->Release();
#define SAFE_DELETE(a) if (a!=NULL) delete(a);
#define ine(a,b,c) ((a>=b)&&(a<=c))
#define Real_version 111
#define sup(a,b) ( (a>b) ? a : b )
#define inf(a,b) ( (a<b) ? a : b )
#define RANDOM_NUM      (((FLOAT)rand())/RAND_MAX)
#define carre(a) ((a)*(a))
#define sig ( (RANDOM_NUM<0.4f) ? -1 : 1 ) 
#define borne(a,b,c) ((a>c)? c : ((a<b)? b : a ))
#define absolue(a) ((a<0)? -a : a)

#define sizeX 800
#define sizeY 600

#include "Logger.h"

struct pck_info
{
DWORD version;
DWORD tX;
DWORD tY;
};

struct Dpoint
{
	unsigned int x;
	unsigned int y;
	void Place(int X,int Y) { x=X;y=Y; };
};

struct DPack
{
DWORD nb_BMP;
DWORD nb_packs;
char  name[256];

Dpoint				*dims;
DPack				**pacs;
LPDIRECTDRAWSURFACE *tex;

LPDIRECTDRAW		ddobj;

~DPack();
DPack(FILE* f,LPDIRECTDRAW device);
DPack(char* nom,LPDIRECTDRAW device);
bool Load(FILE* f);
bool Save(FILE* f);
bool Save(char* nom);

bool Creer_police(LPCSTR nom,DWORD taille);

LPDIRECTDRAWSURFACE Color(unsigned int ,DWORD );
bool Pack_Color(DWORD coul,DPack* dest);

bool Put_BMP(char* nom,int );
bool Add_BMP(char* nom);
bool Add_MANY_BMP(char *nom);
bool Del_BMP(int quel);

bool Add_Pack(char* nom);
bool Del_Pack(int quel);
bool New_Pack();

bool Add_Texture_from_Pack(FILE* f);
bool Save_Texture_to_Pack(int a,FILE* f);

bool Verifie_DD();
};

typedef struct DPack       FAR *LPDPack;

struct _Sprite
{
bool rected;
RECT rc;
DWORD x;
DWORD y;
float priorite;
LPDIRECTDRAWSURFACE surf;
};

struct Renderer
{
_Sprite*		sp;
LPDIRECTDRAWSURFACE  BB;
DWORD			nb_sprites;
DWORD			current_sprite;
RECT			ret;

bool Resizer(int );

bool Add(float priorite,int X,int Y,DPack* pack,DWORD bitmap);
bool Add_char(float priorite,char c,int X,int Y,DPack* pack,DWORD bitmap);

void Trie(int premier,int dernier);
bool Render();
void definir_rect(LONG x,LONG y,LONG tx,LONG ty);

Renderer(LPDIRECTDRAWSURFACE );
~Renderer();
};

#endif